package com.qyhl.party.party.supplement.department;

import com.qyhl.party.common.PartyUrl;
import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.entity.party.PartyZoneBean;

import java.util.List;

public class PartyDepartmentModel implements PartyDepartmentContract.PartyDepartmentModel {
    private PartyDepartmentPresenter mPresenter;

    public PartyDepartmentModel(PartyDepartmentPresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getList(int level, String name) {
        EasyHttp.post(PartyUrl.PARTY_DEPARTMENT_LIST)
                .params("siteId", CommonUtils.getInstance().getSite() + "")
                .params("level", level + "")
                .params("name", name)
                .execute(new SimpleCallBack<List<PartyZoneBean>>() {
                    @Override
                    public void onError(ApiException e) {
                        mPresenter.setError("获取失败！");
                    }

                    @Override
                    public void onSuccess(List<PartyZoneBean> beanList) {
                        mPresenter.setList(beanList);
                    }
                });
    }
}
